﻿Public Class frmDangNhap
    Dim key As Boolean = True

    Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick
        Timer.Interval = 100
        frmChaoMung_Load(sender, e)
    End Sub

    Private Sub frmChaoMung_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer.Enabled = True
        If (key = True And lbChaoMung.Left > 140) Then
            key = False
        End If
        If (key = False And lbChaoMung.Left < 30) Then
            key = True
        End If
        If (key) Then

            lbChaoMung.Left += 5

        Else
            lbChaoMung.Left -= 5
        End If
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Close()
    End Sub

    Private Sub btnDangNhap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDangNhap.Click
        Dim tkDTO As New TaiKhoanDTO
        tkDTO.m_strTenDangNhap = txtTenDangNhap.Text
        tkDTO.m_strMatKhau = txtMatKhau.Text
        Dim a As Integer = TaiKhoanBUS.KTDangNhap(tkDTO)
        If a = 1 Then
            Hide()
            Dim frm As New frmMain
            frm.ShowDialog()
            Close()
        Else
            txtTenDangNhap.Focus()
            txtTenDangNhap.Text = ""
            txtMatKhau.Text = ""
            MessageBox.Show("Đăng nhập thất bại. Vui lòng kiểm tra lại thông tin tài khoản.", "Thông báo")
        End If
    End Sub

    Private Sub lbDangKi_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lbDangKi.LinkClicked
        Dim frm As New frmDangKi
        frm.ShowDialog()
    End Sub
End Class